using OracleInternal.Json.Sql;

namespace OracleInternal.Json.Binary
{
	internal class OracleOsonValueFactory : OsonValueFactory
	{
		internal static OracleOsonValueFactory INSTANCE = new OracleOsonValueFactory();

		internal override OsonAbstractArray CreateArray(OsonContext ctx, int pos)
		{
			return new OsonArray(ctx, pos);
		}

		internal override OsonAbstractObject CreateObject(OsonContext ctx, int pos)
		{
			return new OsonObject(ctx, pos);
		}

		internal override object CreateString(OsonContext ctx, int pos, int len)
		{
			ctx.m_osonBuffer.Position(pos);
			int charArrLen;
			return new OracleJsonString(ctx.m_osonBuffer.ReadString(len, out charArrLen), charArrLen);
		}

		internal override OracleJsonNumber CreateNumber(byte[] raw, TargetType type)
		{
			return new OracleJsonDecimal(raw, type);
		}

		internal override OracleJsonNumber CreateStringNumber(string value)
		{
			return new OracleJsonStringNumber(value);
		}

		internal override OracleJsonNumber CreateDouble(double value)
		{
			return new OracleJsonDouble(value);
		}

		internal override object CreateBinary(byte[] value, bool isId)
		{
			return new OracleJsonBinary(value, isId);
		}

		internal override object CreateTimestamp(byte[] raw)
		{
			return new OracleJsonTimestamp(raw);
		}

		internal override object CreateTimestampTZ(byte[] raw)
		{
			return new OracleJsonTimestampTZ(raw);
		}

		internal override OracleJsonNumber CreateFloat(float flt)
		{
			return new OracleJsonFloat(flt);
		}

		internal override object CreateDate(byte[] raw)
		{
			return new OracleJsonDate(raw);
		}

		internal override object CreateIntervalYM(byte[] value)
		{
			return new OracleJsonIntervalYM(value);
		}

		internal override object CreateIntervalDS(byte[] value)
		{
			return new OracleJsonIntervalDS(value);
		}

		internal override object CreateTrue()
		{
			return OracleJsonValue.TRUE;
		}

		internal override object CreateFalse()
		{
			return OracleJsonValue.FALSE;
		}

		internal override object CreateNull()
		{
			return OracleJsonValue.NULL;
		}
	}
}
